Open memory stream.
bool OpenStream(bool Buffered, bool Dynamic, array<System::Byte> ^% MemStream, System::UInt32 StreamSize, TStreamFormat nFormat);
Parameters |
Description |
bool Buffered |
Specifies if stream is buffered stream. True specifies buffered stream. False specifies non bufferd stream. |
bool Dynamic |
Specifies if stream is dynamic or static. True specifies dynamic stream. False specifies static stream. |
array<System::Byte> ^% MemStream |
Reference of memory block with stream data. |
System::UInt32 StreamSize |
Size of memory block, in bytes. |
TStreamFormat nFormat |
Stream format. This value can't be sfAutodetect. You must specify valid stream format. |
Return Values |
Description |
True |
All OK. |
False |
Error. To get error message read here. |
First block of data needs to be large enough and must contain all data to identify specified stream type.
For sfMp3 stream format, this block of data needs to contain at least one valid mp3 frame.
For sfOgg streamformat, this block must contain enough data to identify ogg type.
For sfWave, this block must contain valid RIFF header.
If this function fails, call this function again with larger block of data or with another block of data.
For sfMp3 stream, 128 kbps at 44100 Hz you need at least 426 bytes without ID3v2 data at stream start. If input block is too small, function will fail. Then you need to send larger block.
Buffered stream allocates internal memory for input data and class makes copy of input data. User can destroy input data because there is copy of this data in internal buffer. Class will manage this internal memory.
If stream is not buffered, function takes only pointer to stream data. User is responsible for this data. So, user must keep this data in memory until function is done with this data. See IsStreamDataFree.
If you specify dynamic stream, you can add new data into this stream with PushDataToStream function. Use OpenStream with small chunk of input data and add rest of data with PushDataToStream function later. Use SetCallbackFunc and callback mechanism to determine when class needs more data. You can't seek or use reverse mode on dynamic stream. If dynamic stream runs out of data, it waits for new data, playing is paused, wave output is still active and class is ready to continue playing when you push new data to stream with PushDataToStream.
If stream is not dynamic, you can't add new data into stream. Class will use only data provided by sMemStream parameter. But this type of stream has no limitation in seek and reverse mode. When this stream runs out of data, playing is stopped.
Open static stream.
FileInfo ^fInfo = gcnew FileInfo(OpenFileDialog1->FileName); long numBytes = (long) fInfo->Length; FileStream ^fStream = gcnew FileStream(OpenFileDialog1->FileName, FileMode::Open, FileAccess::Read); BinaryReader ^br = gcnew BinaryReader(fStream); array<System::Byte> ^stream_data = nullptr; stream_data = br->ReadBytes((int)numBytes); if (! (player->OpenStream(true, false, stream_data, (unsigned int) numBytes, format))) { MessageBox::Show(player->GetError(), "Fatal error", MessageBoxButtons::OK, MessageBoxIcon::Error); } br->Close(); fStream->Close();
Copyright (c) 2010. Zoran Cindori - All rights reserved.
Web: http://libzplay.sourceforge.net/ Email: zcindori@inet.hr |